package com.zmn.plat.admin.controller.product.engineerexamineurl;

import java.util.Objects;

import javax.annotation.Resource;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.common.utils.number.NumberUtil;
import com.zmn.plat.model.entity.product.engineerexamineurl.EngineerExamineUrl;
import com.zmn.plat.services.interfaces.product.engineerexamineurl.EngineerExamineUrlService;

/**
 * 工程师升级考试地址基础查询Controller
 *
 * @author tanghongjun
 * @since 2020-08-19 11:18:36
 */
@RestController
@RequestMapping("/product/engineerexamineurl/")
public class EngineerExamineUrlListController extends EngineerExamineUrlBaseController {

    private Logger logger = LoggerFactory.getLogger(EngineerExamineUrlListController.class);

    @Resource
    private EngineerExamineUrlService engineerExamineUrlService;

    /**
     * 信息
     */
    @RequestMapping("/addEditView")
    @RequiresPermissions("product/engineerexamineurl/addEditView.action")
    public ModelAndView info(@RequestParam(value = "groupId", defaultValue = "0") Integer groupId) {

        EngineerExamineUrl engineerExamineUrl;
        if (groupId == 0) {
            engineerExamineUrl = new EngineerExamineUrl();
        } else {
            engineerExamineUrl = engineerExamineUrlService.findByGroupId(groupId);
            engineerExamineUrl = Objects.isNull(engineerExamineUrl) ? new EngineerExamineUrl() : engineerExamineUrl;
            engineerExamineUrl.setGroupId(groupId);
            engineerExamineUrl
                .setRelateId(NumberUtil.isNullOrZero(engineerExamineUrl.getRelateId()) ? 0 : engineerExamineUrl.getRelateId());
        }

        ModelAndView mav = new ModelAndView("product/engineerexamineurl/detail");
        mav.addObject("engineerExamineUrl", engineerExamineUrl);

        return mav;
    }

}
